package com.zzxx.wechat.controller;

import com.zzxx.wechat.common.enums.ArcteryxSpuStatusEnum;
import com.zzxx.wechat.common.vo.ArcteryxProductReq;
import com.zzxx.wechat.common.vo.ArcteryxProductVo;
import com.zzxx.wechat.result.R;
import com.zzxx.wechat.service.ArcteryxProductService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/arcteryx/product")
public class ArcteryxProductController {

    @Resource
    private ArcteryxProductService arcteryxProductService;

    @PostMapping("/list")
    @ResponseBody
    public R<List<ArcteryxProductVo>> list() {
        List<ArcteryxProductVo> arcteryxProductVos = arcteryxProductService.list();

        return R.ok(arcteryxProductVos);
    }

    @PostMapping("/add")
    @ResponseBody
    public R<Void> add(@RequestBody ArcteryxProductReq req) {
        arcteryxProductService.add(req);
        return R.ok();
    }


    @PostMapping("/delete")
    @ResponseBody
    public R<Void> delete(@RequestBody ArcteryxProductReq req) {
        arcteryxProductService.delete(req);
        return R.ok();
    }

    @PostMapping("/enable")
    @ResponseBody
    public R<Void> enable(@RequestBody ArcteryxProductReq req) {
        arcteryxProductService.updateStatus(req.getProductNo(), ArcteryxSpuStatusEnum.ENABLE);
        return R.ok();
    }
    @PostMapping("/pause")
    @ResponseBody
    public R<Void> pause(@RequestBody ArcteryxProductReq req) {
        arcteryxProductService.updateStatus(req.getProductNo(), ArcteryxSpuStatusEnum.PAUSE);
        return R.ok();
    }
}
